package utils.json;

import java.lang.reflect.Type;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * @author ultrafrog
 * @version 1.0, 2014-11-12
 * @since 1.0
 */
public abstract class Gsons {

	/**  */
	private static Gson gson = null;
	
	static {
		gson = new GsonBuilder().disableHtmlEscaping().create();
	}
	
	/**
	 * @param json
	 * @param type
	 * @return
	 */
	public static <T> T fromJson(String json, Class<T> type) {
		return gson.fromJson(json, type);
	}
	
	/**
	 * @param json
	 * @param type
	 * @return
	 */
	public static <T> List<T> fromJson(String json, Type type) {
		return gson.fromJson(json, type);
	}
	
	/**
	 * @param obj
	 * @return
	 */
	public static String toJson(Object obj) {
		return gson.toJson(obj);
	}
}
